﻿using System;
using Ease.EaseDialog.Runtime.Param;
using Ease.EaseNode.Runtime;
using Sirenix.OdinInspector;

namespace Ease.EaseDialog.Runtime.Data
{
    [Serializable]
    public abstract class BaseDialogData : BaseEaseNodeData
    {
        public abstract string Tip { get; }
        public int id;
        [OnValueChanged(nameof(OnPosChange))] public DialogPos pos = DialogPos.left;
        [OnValueChanged(nameof(OnNameChange))] public string name;

        [OnValueChanged(nameof(OnContentChange))]
        public string content;

#if UNITY_EDITOR

        public override string Key => id.ToString();
#endif

        private void OnPosChange()
        {
#if UNITY_EDITOR
            OnValueChange(new PosChangeParam() {pos = pos});
#endif
        }

        private void OnNameChange()
        {
#if UNITY_EDITOR
            OnValueChange(new StringChangeParam() {valueKey = "name", value = name});
#endif
        }

        private void OnContentChange()
        {
#if UNITY_EDITOR
            OnValueChange(new StringChangeParam() {valueKey = "content", value = content});
#endif
        }
    }
}